#include <iostream>
#include <cstring>

using namespace std;

bool repeatedSubstringPattern(const char* s)
{
    if(s == NULL)
    {
        return false;
    }

    /* 记录字符串的长度 */
    int length = strlen(s);
    if(length <= 1)
    {
        return false;
    }

    for(int window = 1; window <= (length >> 1); window++)
    {
        /* 如果字符串不是窗口的整数倍 */
        if(length % window != 0)
        {
            continue;   
        }

        /* 窗口里面是啥？ */
        /* 填满窗口 */

        char subString[window + 1];
        memset(subString, 0, sizeof(subString));
        strncpy(subString, s, window);

        /* 结束符 */
        subString[window] = '\0';

        bool repeated = false;

        for(int idx = window; idx <= length - window; idx += window)
        {
            if(strncmp(subString, s + idx, window) != 0)
            {
                break;
            }
        }

        if(repeated == true)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    const char * str = "abcabcabcab";
    cout << repeatedSubstringPattern(str) << endl;
    return 0;
}